package cn.net.mugui.net.pc.task;

import java.awt.image.BufferedImage;

import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.Java2DFrameConverter;

import com.mugui.base.base.Autowired;
import com.mugui.base.base.Component;
import com.mugui.base.client.net.auto.AutoTask;
import com.mugui.base.client.net.base.Task;
import com.mugui.base.client.net.task.TaskCycleImpl;

import cn.net.mugui.net.pc.panel.WebCamUI;


@AutoTask
@Component
@Task
public class WebCamTask extends TaskCycleImpl<Frame> {

	Java2DFrameConverter converter = new Java2DFrameConverter();

	@Autowired
	private WebCamUI webcamui;
	
	@Override
	protected void handle(Frame poll) {
		if (!is_run) {
			poll.close();
			return;
		}
		BufferedImage convert = converter.convert(poll);
		webcamui.show(convert);
//		poll.close();
	}

	boolean is_run = false;

	public void start() {
		is_run = true;
	}

	public void stop() {
		is_run = false;
	}

	

}
